package com.xxwy.ddu.common.util;

import com.alibaba.druid.sql.visitor.functions.Char;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.google.common.base.Strings;
import org.apache.commons.lang3.StringUtils;
import org.springframework.core.NamedThreadLocal;
import org.springframework.web.util.WebUtils;

import javax.servlet.ServletRequest;
import javax.servlet.http.HttpServletRequest;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.List;
import java.util.Map;
import java.util.Stack;

/**
 * @author xxwy
 * on 2018/8/14 0014
 */
public class WebUtil {

    public static ThreadLocal<HttpServletRequest> REQUEST = new NamedThreadLocal<HttpServletRequest>(
            "ThreadLocalRequest");

    public static String getParameters(ServletRequest request, String body) {
        Map<String, Object> params = null;
        if (request != null && StringUtils.isBlank(body)) {
            //是html/text
            params = WebUtils.getParametersStartingWith(request, null);
            return params.toString();
        }
        return body;
    }

}
